package com.yhsimon.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author： YHSimon
 * @date： 2021-10-12 14:27
 */
public class InfoCollegeIterator implements Iterator {

    List<Department> departmentList; //以list方式存放
    int index = -1;   //索引

    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    @Override
    public boolean hasNext() {
        if(index>=departmentList.size()-1) {
            return false;
        }else{
            index++;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentList.get(index);
    }

    //空实现remove

    @Override
    public void remove() {

    }
}
